this code will show how to get all files from folders and sub folders from given path

======================================================

<?PHP
/********************************/
/* Author: Noor Ahmad Feroozi	*/
/********************************/

function get_files($dir){
	$files = array();
	if(is_dir($dir)){
		if($dh = opendir($dir)){
			while (($file = readdir($dh)) !== false) {
				if(!($file == '.' || $file == '..')){
					$file = $dir.'/'.$file;
					if(is_dir($file) && $file != './.' && $file != './..'){
						$files = array_merge($files, get_files($file));
					}
					else if(is_file($file)){
						$fullpath = $_SERVER['HTTP_REFERER'];
						$fullpath = str_replace(basename($fullpath),"",$fullpath);
						$fullpath .= substr($file,2);
						$files[] = $fullpath;
					}
				}
			}
		}
	}
	return $files;
}
// Example:
echo "<pre>".print_r(get_files("."),true)."</pre>";
?>